package yutProject_OOP;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MouseEventProcessor implements MouseListener {

	private boolean isRunning = true;

	public boolean isListening() {
		return isRunning;
	}

	public void stopListening() {
		isRunning = false;
	}

	public void startListening() {
		isRunning = false;
	}

	/**
	 * 마우스 이벤트를 제어한다.
	 */
	@Override
	public void mouseClicked(MouseEvent event) {

		switch (event.getButton()) {
		case MouseEvent.BUTTON1:
			mouseLButtonClickProcess(event);
			break;
		case MouseEvent.BUTTON2:
			break;
		case MouseEvent.BUTTON3:
			mouseRButtonClickProcess(event);
			break;
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	private void mouseLButtonClickProcess(MouseEvent event) {
		System.out.println(String.format("(%3d, %3d)에서 마우스 왼쪽 버튼이 클릭되었습니다.", event.getX(), event.getY()));

		switch (Game.getGameMode()) {
		case Title:
			Game.setGameMode(Mode.Game);
			break;
		case Game:
			break;
		case EndTitle:
			break;
		}
	}

	private void mouseRButtonClickProcess(MouseEvent event) {
		System.out.println(String.format("(%3d, %3d)에서 마우스 오른쪽 버튼이 클릭되었습니다.", event.getX(), event.getY()));

		switch (Game.getGameMode()) {
		case Title:
			break;
		case Game:
			Game.setGameMode(Mode.Title);
			break;
		case EndTitle:
			break;
		}
	}
}